import { S } from '../../s';
import { IPSAppDELogicLink } from '../../app/dataentity/ipsapp-delogic-link';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicLink } from './ipsdelogic-link';
import { IPSDELogicLinkGroupCond } from './ipsdelogic-link-group-cond';
import { IPSDELogicNode } from './ipsdelogic-node';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicLinkImpl
  extends PSModelObjectImpl
  implements IPSDELogicLink, IPSAppDELogicLink
{
  protected dstpsdelogicnode: IPSDELogicNode;
  getDstPSDELogicNode(): IPSDELogicNode | null {
    if (this.dstpsdelogicnode != null) return this.dstpsdelogicnode;
    const value = this.M.getDstPSDELogicNode;
    if (value == null) {
      return;
    }
    const ipsdelogic = this.getParentPSModelObject(S._200) as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicnode = ipsdelogic.findPSDELogicNode(value);
    }
    return this.dstpsdelogicnode;
  }

  protected psdelogiclinkgroupcond: IPSDELogicLinkGroupCond;
  getPSDELogicLinkGroupCond(): IPSDELogicLinkGroupCond | null {
    return (
      this.psdelogiclinkgroupcond ||
      (this.psdelogiclinkgroupcond = this.fillObjectModel(
        S._1d8,
        this.M.getPSDELogicLinkGroupCond,
        S._31d,
      ) as IPSDELogicLinkGroupCond)
    );
  }

  protected srcpsdelogicnode: IPSDELogicNode;
  getSrcPSDELogicNode(): IPSDELogicNode | null {
    if (this.srcpsdelogicnode != null) return this.srcpsdelogicnode;
    const value = this.M.getSrcPSDELogicNode;
    if (value == null) {
      return;
    }
    const ipsdelogic = this.getParentPSModelObject(S._200) as IPSDELogic;
    if (ipsdelogic != null) {
      this.srcpsdelogicnode = ipsdelogic.findPSDELogicNode(value);
    }
    return this.srcpsdelogicnode;
  }

  get catchLink(): boolean {
    return this.M.catchLink != null ? this.M.catchLink : false;
  }

  get defaultLink(): boolean {
    return this.M.defaultLink != null ? this.M.defaultLink : false;
  }

  get subCallLink(): boolean {
    return this.M.subCallLink != null ? this.M.subCallLink : false;
  }
  get cls(): string {
    return 'PSDELogicLinkImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1d9 || cls == S._1da) return true;
    return super.instanceof(cls);
  }
}
